using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Collections.Generic;

public partial class upload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string s_rpath = Server.MapPath("~/Files/UpLoadImage/");

        string Datedir = DateTime.Now.ToString("yyyyMMddmmss");
        string updir = s_rpath + "\\" + Datedir;
        Session["PicMap"] = Datedir;
		try
		{
            if (this.Page.Request.Files.Count > 0)
            {
                for (int j = 0; j < this.Page.Request.Files.Count; j++)
                {

                    HttpPostedFile uploadFile = this.Page.Request.Files[j];

                    if (uploadFile.ContentLength > 0)
                    {
                        if (!Directory.Exists(updir))
                        {
                            Directory.CreateDirectory(updir);
                        }
                        string extname = Path.GetExtension(uploadFile.FileName);
                        string fullname = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
                        string filename = uploadFile.FileName;

                        uploadFile.SaveAs(string.Format("{0}\\{1}", updir, filename));
                    }
                }
            }
		}
		catch
		{
			// If any kind of error occurs return a 500 Internal Server error
			Response.StatusCode = 500;
			Response.Write("An error occured");
			Response.End();
		}
		finally
		{
		}
	
	}
}
